package com.nd.service;

import com.nd.dao.SystemMapper;
import com.nd.pojo.bo.ConfigExpressBo;
import com.nd.pojo.bo.ConfigMallBo;
import com.nd.pojo.vo.ConfigExpressVo;
import com.nd.pojo.vo.ConfigOrderVo;
import com.nd.pojo.vo.ConfigWxVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author : PengFei Zhang
 * @Data :2021/6/6  11:25
 * @Description :
 */
//配置管理  zpf
@Service
public class ConfigurationManagementServiceImpl implements ConfigurationManagementService {

    @Autowired
    SystemMapper systemMapper;


    //商场配置
    @Override
    public ConfigMallBo selectConfigMall() {
        ConfigMallBo configMallBo = new ConfigMallBo();
        configMallBo.setCskaoyanmall_mall_name(systemMapper.selectSystemByKeyname("cskaoyan_mall_mall_name"));
        configMallBo.setCskaoyanmall_mall_qq(systemMapper.selectSystemByKeyname("cskaoyan_mall_mall_qq"));
        configMallBo.setCskaoyanmall_mall_phone(systemMapper.selectSystemByKeyname("cskaoyan_mall_mall_phone"));
        configMallBo.setCskaoyanmall_mall_address(systemMapper.selectSystemByKeyname("cskaoyan_mall_mall_address"));
        return configMallBo;
    }

    @Override
    public void updateConfigMall(ConfigMallBo configMallBo) {
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_mall_name", configMallBo.getCskaoyanmall_mall_name());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_mall_address", configMallBo.getCskaoyanmall_mall_address());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_mall_phone", configMallBo.getCskaoyanmall_mall_phone());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_mall_qq", configMallBo.getCskaoyanmall_mall_qq());
    }

    //运费配置
    @Override
    public ConfigExpressVo selectConfigExpress() {
        ConfigExpressVo configExpressVo = new ConfigExpressVo();
        configExpressVo.setCskaoyanmall_express_freight_min(systemMapper.selectSystemByKeyname("cskaoyan_mall_express_freight_value"));
        configExpressVo.setCskaoyanmall_express_freight_value(systemMapper.selectSystemByKeyname("cskaoyan_mall_express_freight_min"));
        return configExpressVo;
    }

    @Override
    public void updateConfigExpress(ConfigExpressBo configExpressBo) {
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_express_freight_value", configExpressBo.getCskaoyanmall_express_freight_value());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_express_freight_min", configExpressBo.getCskaoyanmall_express_freight_min());
    }

    //订单配置
    @Override
    public ConfigOrderVo selectConfigOreder() {
        ConfigOrderVo configOrderVo = new ConfigOrderVo();
        configOrderVo.setCskaoyanmall_order_comment(systemMapper.selectSystemByKeyname("cskaoyan_mall_order_comment"));
        configOrderVo.setCskaoyanmall_order_unconfirm(systemMapper.selectSystemByKeyname("cskaoyan_mall_order_unconfirm"));
        configOrderVo.setCskaoyanmall_order_unpaid(systemMapper.selectSystemByKeyname("cskaoyan_mall_order_unpaid"));
        return configOrderVo;
    }

    @Override
    public void updateConfigOreder(ConfigOrderVo configOrderVo) {
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_order_comment", configOrderVo.getCskaoyanmall_order_comment());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_order_unconfirm", configOrderVo.getCskaoyanmall_order_unconfirm());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_order_unpaid", configOrderVo.getCskaoyanmall_order_unpaid());
    }


    //小程序配置
    @Override
    public ConfigWxVo selectConfigWx() {
        ConfigWxVo configWxVo = new ConfigWxVo();
        configWxVo.setCskaoyanmall_wx_catlog_goods(systemMapper.selectSystemByKeyname("cskaoyan_mall_wx_catlog_goods"));
        configWxVo.setCskaoyanmall_wx_catlog_list(systemMapper.selectSystemByKeyname("cskaoyan_mall_wx_catlog_list"));
        configWxVo.setCskaoyanmall_wx_index_brand(systemMapper.selectSystemByKeyname("cskaoyan_mall_wx_index_brand"));
        configWxVo.setCskaoyanmall_wx_index_hot(systemMapper.selectSystemByKeyname("cskaoyan_mall_wx_index_hot"));
        configWxVo.setCskaoyanmall_wx_share(systemMapper.selectSystemByKeyname("cskaoyan_mall_wx_share"));
        configWxVo.setCskaoyanmall_wx_index_topic(systemMapper.selectSystemByKeyname("cskaoyan_mall_wx_index_topic"));
        configWxVo.setCskaoyanmall_wx_index_new(systemMapper.selectSystemByKeyname("cskaoyan_mall_wx_index_new"));
        return configWxVo;
    }

    @Override
    public void updateConfigWx(ConfigWxVo configWxVo) {
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_wx_catlog_goods",configWxVo.getCskaoyanmall_wx_catlog_goods());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_wx_catlog_list",configWxVo.getCskaoyanmall_wx_catlog_list());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_wx_index_hot",configWxVo.getCskaoyanmall_wx_index_hot());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_wx_share",configWxVo.getCskaoyanmall_wx_share());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_wx_index_topic",configWxVo.getCskaoyanmall_wx_index_topic());
        systemMapper.updateKeyValueByKeyName("cskaoyan_mall_wx_index_new",configWxVo.getCskaoyanmall_wx_index_new());

    }

}
